<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>_${customer.customerName}_上架任务分配列表</title>
<script type="text/javascript">
 
  //领取任务 
  function takeTask(taskId){
	  $.ajax({
			type:'post',
			url:'${ctx}/v2_instorageUpDispatch/ajaxTakeTask',
			data:{
				taskId:taskId
			},
			dataType:'json',
			success:function(data) {
			    if(data==true){
			      $("#queryForm").submit();
			    }else{
			      alert("网络繁忙，请稍后重试...");
			    }
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
	   });
  }
  

</script>
</head>

<body>
<section class="content">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
	    <thead>
			<th style="vertical-align: middle; color: white; " colspan="13" bgcolor="#3c8dbc"><i class="fa fa-list"/> 已分配任务</th>
		</thead>
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>作业仓库</th>
			    <th>入库类型</th>
			    <th>入库单号</th>
			    <th>商品类型</th>
			    <th>创建时间</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${myTaskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>
			   <c:forEach items="${customerList}" var="customer"> 
						<c:if test="${t.instorageBill.customerCode eq customer.customerCode}">${customer.customerName}</c:if>
					</c:forEach>
			  </td>
			   <td>
			   <c:forEach items="${warehouseList}" var="w" >
					   <c:if test="${t.instorageBill.inwarehouseCode eq w.groupCode }">${w.groupName}</c:if>
				   </c:forEach>
			   </td>
			   <td>
				  <c:if test="${t.instorageBill.billType eq 'customer' }"><font color=red>采购入库</font></c:if> 
				  <c:if test="${t.instorageBill.billType eq 'allot' }"><font color=green>调拨入库</font></c:if>
				  <c:if test="${t.instorageBill.billType eq 'cancelOrder' }"><font color=blue>取消单入库</font></c:if>
				  <c:if test="${t.instorageBill.billType eq 'returnOrder' }"><font color=black>退回件入库</font></c:if>
				  <c:if test="${t.instorageBill.billType eq 'preOrder' }"><font color=black>预约入库</font></c:if>
			   </td>
			   <td>${t.instorageBill.billCode}</td>
				<td>
				    <c:if test="${t.instorageBill.errorFlag eq 'error' }"><font color=red>报损件</font></c:if> 
				    <c:if test="${t.instorageBill.errorFlag eq 'noterror' }">完好件</c:if> 
				</td>
			   <td>${fn:substring(t.instorageBill.createTime,0,19)}</td>
			    <td>
			    <c:choose>
			    	<c:when test="${t.instorageBill.status eq '6' }">已取消</c:when>
			    	<c:otherwise>
				    	<c:if test="${t.status eq '0'}">创建任务</c:if>
				     	<c:if test="${t.status eq '1'}">领取任务</c:if>
				     	<c:if test="${t.status eq '2'}">完成点收</c:if>
			    	</c:otherwise>
			    </c:choose>
			   </td>
			   <td>
				   <c:if test="${t.instorageBill.status ne '6' }">
				      <c:if test="${t.status eq '1'}">
				        <a href="${ctx}/v2_instorageUpDispatch/toDispatchMain/${t.id}"   class="btn btn-primary" >开始分配</a>
				      </c:if>
			      </c:if>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
	<!-- 未分配的任务 -->
	<table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;">
		<thead>
			<th style="vertical-align: middle; color: white; " colspan="13" bgcolor="#3c8dbc"> <i class="fa fa-list" /> 未分配任务</th>
		</thead>
		<tr >
		   <td colspan="13">
		     <form class="form-search" id="queryForm" method="post" action="${ctx}/v2_instorageUpDispatch/toUpTaskDispatchPage" style="margin-top: 10px;">
				
			  <label style="margin-left: 10px;">商家用户:</label>
			  <select class="required"  id="_customerCode" name="_customerCode" onchange="ajaxAreaGroup(this);" style="width: 100px;" >
				        <option value=""></option>
						<c:forEach items="${customerList}" var="customer">
							<option value="${customer.customerCode}"
							  <c:if test="${param._customerCode eq customer.customerCode }">selected=selected</c:if>
							>${customer.customerName}</option>
						</c:forEach>
				</select> 
				
				<label style="margin-left: 10px;">作业仓库</label>
				 <select  name="_warehouseCode"  id="_warehouseCode" style="width: 100px;">
					<option value=""></option>
					<c:forEach items="${warehouseList}" var="w" >
					   <option value="${w.groupCode}" 
					   <c:if test="${param._warehouseCode eq w.groupCode }">selected=selected</c:if>
					   >${w.groupName}</option>
				   </c:forEach>
				</select>
				
			    <button class="btn btn-primary" type="submit" style="margin-left: 10px; ">搜索</button>
		    </form>
		   </td>
		</tr>
		
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>作业仓库</th>
			    <th>入库类型</th>
			    <th>入库单号</th>
			     <th>商品类型</th>
			    <th>创建时间</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${untakedTaskList}" var="t" varStatus="i">
			<tr>
			    <td>${i.count}</td>
			   <td>
			   <c:forEach items="${customerList}" var="customer"> 
						<c:if test="${t.instorageBill.customerCode eq customer.customerCode}">${customer.customerName}</c:if>
					</c:forEach></td>
			   <td><c:forEach items="${warehouseList}" var="w" >
					   <c:if test="${t.instorageBill.inwarehouseCode eq w.groupCode }">${w.groupName}</c:if>
				   </c:forEach>
			   </td>
			   <td>
				  <c:if test="${t.instorageBill.billType eq 'customer' }"><font color=red>采购入库</font></c:if> 
				  <c:if test="${t.instorageBill.billType eq 'allot' }"><font color=green>调拨入库</font></c:if>
				  <c:if test="${t.instorageBill.billType eq 'cancelOrder' }"><font color=blue>取消单入库</font></c:if>
				  <c:if test="${t.instorageBill.billType eq 'returnOrder' }"><font color=black>退回件入库</font></c:if>
				  <c:if test="${t.instorageBill.billType eq 'preOrder' }"><font color=black>预约入库</font></c:if>
			   </td>
			   <td>${t.instorageBill.billCode}</td>
			   <td>
				    <c:if test="${t.instorageBill.errorFlag eq 'error' }"><font color=red>报损件</font></c:if> 
				    <c:if test="${t.instorageBill.errorFlag eq 'noterror' }">完好件</c:if> 
				</td>
			   <td>${fn:substring(t.instorageBill.createTime,0,19)}</td>
			   <td>
			   <c:choose>
			    	<c:when test="${t.instorageBill.status eq '6' }">已取消</c:when>
			    	<c:otherwise>
				    	<c:if test="${t.status eq '0'}">创建任务</c:if>
				     	<c:if test="${t.status eq '1'}">领取任务</c:if>
				     	<c:if test="${t.status eq '2'}">完成点收</c:if>
			    	</c:otherwise>
			    </c:choose>
				</td>
			   <td>
			   		<c:if test="${t.instorageBill.status ne '6' }">
			      		<input type="button" class="btn btn-primary" onclick="takeTask('${t.id}');" value="领取任务"/>
			      	</c:if>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
		
	</table>
	
</section>
</body>
</html>
